<template>

  <div>
    <!-- 高度用size -->
    <el-cascader
      :value="value"
      size="mini"
      class="inputW"
      :options="depts"
      :props="selectProps"
      separator="-"
      @change="handleChange"
    />

  </div>
</template>

<script>
import { getDeptsApi } from '@/api/department'
import { transListToTreeData } from '@/utils/index'
export default {
  props: {
    value: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      depts: [],
      selectProps: {
        value: 'id',
        label: 'name'
      }
    }
  },
  created() {
    this.getDepartmentList()
  },
  methods: {
    async getDepartmentList() {
      this.depts = transListToTreeData(await getDeptsApi())
    },
    handleChange(currentNode) {
      this.$emit('input', currentNode[currentNode.length - 1])
    }
  }
}
</script>

<style scoped lang="scss">

.inputW {
   width: 380px
 }

</style>
